package com.junmoo.www.config.mqtt;

import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class MqttCallbackConfig implements MqttCallback {
    //连接异常断开后，调用
    @Override
    public void connectionLost(Throwable throwable) {
        log.info("连接断开，可以做重连");
    }
    //消息到达后，调用
    @Override
    public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
        log.info("接收到消息");
    }
    //消息发送成功后，调用
    @Override
    public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
        log.info("消息发送成功");
    }
}
